package com.haoan.index.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import com.haoan.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.haoan.common.annotation.Log;
import com.haoan.common.core.controller.BaseController;
import com.haoan.common.core.domain.AjaxResult;
import com.haoan.common.enums.BusinessType;
import com.haoan.index.domain.LcBusiness;
import com.haoan.index.service.LcBusinessService;
import com.haoan.common.utils.poi.ExcelUtil;
import com.haoan.common.core.page.TableDataInfo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 业务Controller
 * 
 * @author autoGen
 * @date 2025-03-21
 */
@Api(value="业务",tags = "业务")
@RestController
@Anonymous
@RequestMapping("/index/lcBusiness")
public class LcBusinessController extends BaseController
{
    @Resource
    private LcBusinessService lcBusinessService;

    /**
     * 查询业务列表
     */
    @ApiOperation("查询业务列表")
    @PreAuthorize("@ss.hasPermi('index:lcBusiness:list')")
    @GetMapping("/list")
    public TableDataInfo list(LcBusiness lcBusiness)
    {
        startPage();
        List<LcBusiness> list = lcBusinessService.selectLcBusinessList(lcBusiness);
        return getDataTable(list);
    }

    /**
     * 导出业务列表
     */
    @ApiOperation("导出业务列表")
    @PreAuthorize("@ss.hasPermi('index:lcBusiness:export')")
    @Log(title = "业务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LcBusiness lcBusiness)
    {
        List<LcBusiness> list = lcBusinessService.selectLcBusinessList(lcBusiness);
        ExcelUtil<LcBusiness> util = new ExcelUtil<LcBusiness>(LcBusiness.class);
        util.exportExcel(response, list, "业务数据");
    }

    /**
     * 获取业务详细信息
     */
    @ApiOperation("获取业务详细信息")
    @PreAuthorize("@ss.hasPermi('index:lcBusiness:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(lcBusinessService.selectLcBusinessById(id));
    }

    /**
     * 新增业务
     */
    @ApiOperation("新增业务")
    @PreAuthorize("@ss.hasPermi('index:lcBusiness:add')")
    @Log(title = "业务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LcBusiness lcBusiness)
    {
        return toAjax(lcBusinessService.insertLcBusiness(lcBusiness));
    }

    /**
     * 修改业务
     */
    @ApiOperation("修改业务")
    @PreAuthorize("@ss.hasPermi('index:lcBusiness:edit')")
    @Log(title = "业务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LcBusiness lcBusiness)
    {
        return toAjax(lcBusinessService.updateLcBusiness(lcBusiness));
    }

    /**
     * 删除业务
     */
    @ApiOperation("删除业务")
    @PreAuthorize("@ss.hasPermi('index:lcBusiness:remove')")
    @Log(title = "业务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(lcBusinessService.deleteLcBusinessByIds(ids));
    }
}
